home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-01-01 | 2.9 KB | 98 lines | [TEXT/MPS ] |
- // Copyright © 1991 Apple Computer, Inc. All rights reserved.
- // Example of a modal dialog with a PICT inside, with some additional
- // TEditText control.
- // Kent Sandvik DTS
-
- #include "UDialogs.h"
-
- extern "C" char* memcpy(void*, void*, int);
- #define pstrcpy(p,q) memcpy(p, q, q[0]+1) // added for translation: Pascal strcpy
-
- const long kFileType = 'MOOF';
- const short kModalID = 3000;
- const short cName = 4000;
- const short kMoof = 9999;
-
- //============================================================================
- #pragma segment AInit
-
- pascal void TDialogsApplication::IDialogsApplication()
- {
- this->IApplication(kFileType);
-
- if (gDeadStripSuppression){ // get a needed TPicture object
- TPicture* aPicture = new TPicture;
- }
- }
-
-
- //----------------------------------------------------------------------------
- pascal void TDialogsApplication::HandleFinderRequest()
- {
- // we don't handle Finder requests
- }
-
-
- //------------------------------------------------------------------------------
- #pragma segment ASelCommand
- pascal TCommand * TDialogsApplication::DoMenuCommand(CmdNumber aCmdNumber)
- {
- switch (aCmdNumber){
-
- case cName:
- this->ShowModalDialog(); // show dialog box
- return gNoChanges; // return dummy command object; not Undoable
-
- default: // always do this, so other objects get a chance
- return inherited::DoMenuCommand(aCmdNumber);
-
- }
- }
-
-
- //------------------------------------------------------------------------------
- #pragma segment ARes
- pascal void TDialogsApplication::DoSetupMenus()
- {
- inherited::DoSetupMenus(); // always do this, so other objects get chance
- Enable(cName, true);
- }
-
-
- //------------------------------------------------------------------------------
- #pragma segment ASelCommand
- pascal void TDialogsApplication::ShowModalDialog()
- {
- const IDType kDialogView = 'dlog'; // dialog view identifier
- const IDType kName = 'name'; // edit text identifier
- const IDType kOK = 'okok'; // OK button identifier
- const IDType kCancel = 'cncl'; // Cancel button identifier
- const IDType kPict = 'pic1'; // PICT view
-
- Str255 userName;
-
- TWindow *aWindow = NewTemplateWindow(kModalID, NULL);
- TDialogView *aDialogView = (TDialogView *) aWindow->FindSubView(kDialogView);
- TEditText *anEditText = (TEditText *) aWindow->FindSubView(kName);
- TPicture *aPicture = (TPicture *) aWindow->FindSubView(kPict);
-
-
- PicHandle aHandle = GetPicture(kMoof); // get PICT
- aPicture->SetPicture(aHandle,TRUE); // draw it into the window
-
- IDType dismisser = aDialogView->PoseModally(); // show the modal dialog
-
- #if qDebug
- if (dismisser == kOK) {
- anEditText->GetText(userName);
- printf("The user typed %P in the box\n", userName);
- };
- if (dismisser == kCancel)
- printf("The user cancelled the box\n");
- #endif
-
- aWindow->Close(); // dispose of the dialog window
- }
-
-
- // THE END ---------------------------------------------------------------------